package com.example.demo.entity.vo;

import com.example.demo.entity.pojo.Book;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class BookVo {
    //图书名称
    private String name;
    //类型id
    private String type;
    //价格
    private double price;
    //作者
    private String author;
    //年份
    private int year;
    //简介
    private String indroduction;
    //图片地址
    private String url;
    //出版社
    private String press;
    //数量
    private int count;

    public BookVo(Book book) {
        this.author = book.getAuthor();
        this.name = book.getName();
        this.price = book.getPrice();
        this.press = book.getPress();
        this.year = book.getYear();
        this.indroduction = book.getIndroduction();
        this.url = book.getUrl();
        if (book.getTypeId() == 1){
            this.type = "小说";
        }
        if (book.getTypeId() == 2){
            this.type = "经典";
        }
        if (book.getTypeId() == 3){
            this.type = "科学";
        }
        if (book.getTypeId() == 4){
            this.type = "言情";
        }
        this.count = book.getCount();
    }
}
